﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Media.Imaging;

namespace Studio77.SuperLink.Views
{
    public partial class LinkCard : UserControl
    {
        public LinkCard()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 行号
        /// </summary>
        public int X { get; set; }

        /// <summary>
        /// 列号
        /// </summary>
        public int Y { get; set; }

        /// <summary>
        /// 区分不同的块
        /// </summary>
        public int Value { get; set; }

        /// <summary>
        /// 设置选中状态
        /// </summary>
        public void SetSelectedCard()
        {
            this.imgSelector.Visibility = System.Windows.Visibility.Visible;
            this.StoryboardSelector.RepeatBehavior = RepeatBehavior.Forever;
            this.StoryboardSelector.Begin();

            this.imgFinder.Visibility = System.Windows.Visibility.Collapsed;
            this.StoryboardFinder.Stop();
        }

        /// <summary>
        /// 设置成未选中状态
        /// </summary>
        public void SetUnSelectedCard()
        {
            this.imgSelector.Visibility = System.Windows.Visibility.Collapsed;
            this.StoryboardSelector.Stop();

            this.imgFinder.Visibility = System.Windows.Visibility.Collapsed;
            this.StoryboardFinder.Stop();
        }

        /// <summary>
        /// 设置成寻找状态
        /// </summary>
        public void SetFind()
        {
            this.imgSelector.Visibility = System.Windows.Visibility.Collapsed;
            this.StoryboardSelector.Stop();

            this.imgFinder.Visibility = System.Windows.Visibility.Visible;
            this.StoryboardFinder.RepeatBehavior = RepeatBehavior.Forever;
            this.StoryboardFinder.Begin();
        }

        public void SetCardValue(int value, int columnCount)
        {
            string uri = string.Empty;
            if (columnCount == 4)
            {
                uri = "/Images/GameItem/cute_somthing_" + (value + 1).ToString("D2") + ".png";
            }
            else if (columnCount == 6)
            {
                uri = "/Images/GameItem2/cute_somthing_" + (value + 1).ToString("D2") + ".png";
            }
            else
            {
                uri = "/Images/GameItem3/cute_somthing_" + (value + 1).ToString("D2") + ".png";
            }
            BitmapImage bitmap = new BitmapImage(new Uri(uri, UriKind.RelativeOrAbsolute));
            this.gameImage.Source = bitmap;
            Value = value;
        }
    }
}
